package stone;

import java.io.IOException;

public class ParseException extends Exception {

	private static final long serialVersionUID = -3679864665417693898L;

	public ParseException(Token t){
		this("", t);
	}
	
	public ParseException(String msg, Token t){
		super("syntax error around " + location(t) + ". " + msg);
	}
	
	private static String location(Token t){
		if(t == Token.EOF)
			return "this last line";
		else
			return "\"" + t.getText() + "\" at line " + t.getLineNumber(); 
	}
	
	public ParseException(IOException e){
		super(e);
	}
	
	public ParseException(String msg){
		super(msg);
	}
}
